package com.blb.demo2;

public class Aobing extends Thread {
    private boolean flag = false;

    public boolean isFlag() {
        return flag;
    }

    @Override
    public void run() {

        try {
            Thread.sleep(1000);
            flag = true;
            System.out.println("flag" + flag);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }


    public static void main(String[] args) {
        Aobing aobing = new Aobing();
        aobing.start();
        for (; ; ) {
            synchronized (aobing){

                if (aobing.isFlag()) {
                    System.out.println("有点东西");
                }

            }
        }

    }
}
